package com.lanxiao.cloud.modules.dept.application;

import com.lanxiao.cloud.modules.dept.application.assembler.DeptAssembler;
import com.lanxiao.cloud.modules.dept.application.dto.DeptCmdAdd;
import com.lanxiao.cloud.modules.dept.application.dto.DeptCmdUpdate;
import com.lanxiao.cloud.modules.dept.domain.service.IDeptService;
import org.springframework.stereotype.Component;

/**
 * @author ：qiaoliang
 * @date ：2021-10-26
 */
@Component
public class DeptCmdManager {

  private final IDeptService deptService;
  private final DeptAssembler deptAssembler;

  public DeptCmdManager(IDeptService deptService,
      DeptAssembler deptAssembler) {
    this.deptService = deptService;
    this.deptAssembler = deptAssembler;
  }

  /**
   *  新增部门
   *
   * @author ：qiaoliang
   * @param add : 部门信息
   * @date 2021-10-26 11:30
   */
  public void save(DeptCmdAdd add) {
    deptService.saveDept(deptAssembler.toDept(add));
  }

  /**
   *  修改部门
   *
   * @author ：qiaoliang
   * @param id : 部门ID
   * @param update : 部门信息
   * @date 2021-10-26 11:30
   */
  public void update(Long id, DeptCmdUpdate update) {
    deptService.updateDept(deptAssembler.toDept(id, update));
  }

}
